<template>
  <!--    编辑-->
  <div class="add">
    <el-dialog
      title="新增"
      :visible.sync="this.$store.state.add"
      width="30%"
      :before-close="beforeClose"
    >
      <div>
        <el-form
          :label-position="labelPosition"
          label-width="1rem"
          :model="formLabelAlign"
        >
          <el-form-item label="所属图册：">
            <el-select
              v-model="formLabelAlign.type"
              placeholder="请选择活动区域"
              style="width: 3.92rem"
            >
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="文件名称：">
            <el-input
              v-model="formLabelAlign.name"
              aria-placeholder="请输入文件名称"
              maxlength="200"
            ></el-input>
          </el-form-item>
        </el-form>
        <div class="tag">
          <span>添加标签：</span>
          <div>
            <tagsGroup :show="true"></tagsGroup>
          </div>
        </div>
        <div class="upload">
          <span>上传文件：</span>
          <el-upload
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :file-list="fileList"
            list-type="picture"
            accept=".jpg,.png"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">
              只能上传jpg/png文件，且不超过500kb
            </div>
          </el-upload>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import tagsGroup from './tagsGroup'
export default {
  components: {
    tagsGroup,
  },
  data() {
    return {
      fileList: [],
      labelPosition: 'right',
      formLabelAlign: {
        name: 'hyb',
        type: '',
      },
    }
  },
  created() {},
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList)
    },
    handlePreview(file) {
      console.log(file)
    },
    beforeUpload(file) {
      console.log(file)
    },
    confirm() {
      console.log(this.formLabelAlign)
      this.$store.commit('changeAdd', false)
    },
    cancel() {
      this.$store.commit('changeAdd', false)
    },
    beforeClose() {
      this.$store.commit('changeAdd', false)
    },
  },
}
</script>

<style lang="scss" scoped>
.add {
  ::v-deep.el-dialog__body,
  ::v-deep.el-dialog__footer {
    background: #474747;
    color: #ffffff;
  }
  ::v-deep.el-dialog__header {
    background: #3e3d3d;
    & span {
      color: #ffffff;
    }
  }
  ::v-deep.el-form-item__label {
    color: #ffffff;
  }
  ::v-deep.el-input__inner {
    background: #383838;
    border-radius: 5px;
    color: #ffffff;
    border: none;
  }
  ::v-deep.upload-demo {
    padding: 0.3rem 0 0 0.16rem;
    margin-top: -0.2rem;
  }
}
.tag {
  display: flex;
  span {
    margin-left: 20px;
    font-size: 14px;
  }
  div {
    width: 316px;
    height: 60px;
    display: flex;
    padding-top: 3px;
    box-sizing: border-box;
    margin-left: 9px;
    background: #3e3d3d;
    border-radius: 5px;
    margin-bottom: 6px;
    .group {
      height: 50px;
    }
  }
}

.upload {
  display: flex;
  span {
    margin-left: 20px;
    margin-right: 10px;
  }
}
</style>
